﻿package hunterCommonlib.core 
{
	import flash.display.InteractiveObject;
	
	/**
	 * ...
	 * @author ...
	 */
	public class HEventManager 
	{
		public var target:InteractiveObject;
		private var _events:Array;
		public function HEventManager() 
		{
			_events = new Array();
		}
		public function addEvent(type:String, callback:Function):void {
			target.addEventListener(type, callback);
			_events.push([type, callback]);
		}
		public function clearEvent():void {
			for (var i = 0; i < _events.length; i++) {
				target.removeEventListener(_events[i][0], _events[i][1]);
			}
			_events = new Array();
		}
		public function removeEvent(type:String, callback:Function):void {
			for (var i = 0; i < _events.length; i++) {
				if (type == _events[i][0] && callback == _events[i][1]) {
					target.removeEventListener(_events[i][0], _events[i][1]);
					_events.splice(i, 1);
					break;
				}
			}
		}
	}
	
}